<template>
        <el-dialog top="5%" title="新增" v-model="editFormVisible" :close-on-click-modal="false">
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-form-item label="项目名称" prop="FName">
                    <el-input v-model="form.FName"></el-input>
                </el-form-item>
                <el-form-item label="项目建设内容">
                    <el-input  :autosize="{ minRows: 2}" type="textarea" v-model="form.FContent"></el-input>
                </el-form-item>
                <el-form-item label="项目地址">
                    <el-input v-model="form.FAddress"></el-input>
                </el-form-item>
                <el-form-item label="建设期限">
                    <el-date-picker type="month" placeholder="开始年限" v-model="form.FDeadlineBeg"  style="width: 120px"></el-date-picker>
                    <span>---</span>
                    <el-date-picker type="month" placeholder="结束年限" v-model="form.FDeadlineEnd"  style="width: 120px"></el-date-picker>
                </el-form-item>
                <el-form-item label="总投资额(万元)">
                    <el-input-number  :controls="false" :min="0" v-model="form.FAmount" style="width: 100%"></el-input-number>
                </el-form-item>
                <el-form-item label="固定投资额(万元)">
                    <el-input-number  :controls="false" :min="0" v-model="form.FFixAmount" style="width: 100%"></el-input-number>
                </el-form-item>
                <el-form-item label="项目来源"  prop="FSource">
                    <sy-select v-model="form.FSource"  valueKey="FName"
                               optionData="server/system/SetType.ashx?cmd=GetOptions&FType=5">
                    </sy-select>
                </el-form-item>
                <el-form-item label="项目进度"  prop="FStatus">
                    <sy-select v-model="form.FStatus"  valueKey="FName"
                               optionData="server/system/SetType.ashx?cmd=GetOptions&FType=4">
                    </sy-select>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input type="textarea" v-model="form.FNote"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="editFormVisible = false">取 消</el-button>
                <el-button  v-if="authEdit"   type="primary" @click="save" :loading="loading">保存</el-button>
            </div>
      </el-dialog>
</template>

<script>
    import util from '../../common/util'
    export default {
        data() {
            return {
                authEdit:false,
                form: {},
                rules: {
                    FName: [{required: true,message: '请输入项目名称', trigger: 'blur'}]
                },
                loading:false,
                editFormVisible:false
            }
        },
        methods: {
            switchLoading(flag){
                this.loading = flag
            },
            _openEdit(record,authEdit) {
                this.authEdit = authEdit
                this.editFormVisible = true;
                this.form = Object.assign({},record,{Collections:""})
            },
            _openAdd(record) {
                this.authEdit = true
                this.editFormVisible = true
                let form = {FID:0,
                    FDeadlineBeg:null,
                    FDeadlineEnd:null}
                this.form = Object.assign(form,record)
            },
            save:function () {
                util.post("server/customer/Project.ashx?cmd=Save",this.form,this.switchLoading,result=> {
                    util.msgSuc("保存成功")
                    this.editFormVisible = false
                    this.$emit("onSaveSuc",this.form)
                })
            }
        },
        mounted() {

        }
    }
</script>
